package com.ktjy.controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jjx
 * @since 2025-07-23
 */

import com.ktjy.pojo.SysUser;
import com.ktjy.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/sys/user")
public class SysUserController {
    @Autowired
    ISysUserService sysUserService;

    @GetMapping("/view/{id}")
   public Map<String,Object> view(@PathVariable("id") Long id){
        SysUser sysUser = sysUserService.getUser(id);

        Map<String,Object> map=new HashMap<>();
        map.put("code",200);
        map.put("msg","查询成功");
        map.put("data",sysUser);

        return map;
    }

    @PostMapping("/save")
    public Map<String,Object> saveOrUpdate(SysUser sysUser){
        sysUserService.saveOrUpdateUser(sysUser);

        Map<String,Object> map=new HashMap<>();
        map.put("code",200);
        map.put("msg","修改成功");
        map.put("data",sysUser);

        return map;
    }
}
